<template>
  <div>
    <el-form :inline="true" :model="formWorkInfo" class="demo-form-inline">
      <el-form-item label="标题">
        <el-input v-model="formWorkInfo.title" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item label="招聘单位">
        <el-input v-model="formWorkInfo.place" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item label="招聘职位">
        <el-input v-model="formWorkInfo.name" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item label="岗位性质">
        <el-select v-model="formWorkInfo.type" placeholder="请选择">
          <el-option
            v-for="item in workType"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="单位地址">
        <el-input
          v-model="formWorkInfo.location"
          placeholder="审批人"
        ></el-input>
      </el-form-item>
      <el-form-item label="工作时间">
        <el-input
          v-model="formWorkInfo.worktime"
          placeholder="审批人"
        ></el-input>
      </el-form-item>
      <el-form-item label="工作地点">
        <el-input
          v-model="formWorkInfo.workplace"
          placeholder="审批人"
        ></el-input>
      </el-form-item>
      <el-form-item label="工作报酬">
        <el-input v-model="formWorkInfo.pay" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item label="截止时间">
        <el-date-picker
          v-model="formWorkInfo.deadline"
          type="date"
          placeholder="选择日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="性别要求">
        <el-select v-model="formWorkInfo.sex" placeholder="请选择">
          <el-option
            v-for="item in workSex"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="招聘人数">
        <el-input v-model="formWorkInfo.people" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item label="年纪要求">
        <el-input v-model="formWorkInfo.grade" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item label="校区要求">
        <el-input v-model="formWorkInfo.place" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item label="工作内容">
        <el-input v-model="formWorkInfo.need" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="addWorkInfo">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
Date.prototype.Format = function(fmt) {
  //author: meizz
  var o = {
    "M+": this.getMonth() + 1, //月份
    "d+": this.getDate(), //日
    "h+": this.getHours(), //小时
    "m+": this.getMinutes(), //分
    "s+": this.getSeconds(), //秒
    "q+": Math.floor((this.getMonth() + 3) / 3), //季度
    S: this.getMilliseconds() //毫秒
  };
  if (/(y+)/.test(fmt))
    fmt = fmt.replace(
      RegExp.$1,
      (this.getFullYear() + "").substr(4 - RegExp.$1.length)
    );
  for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt))
      fmt = fmt.replace(
        RegExp.$1,
        RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
      );
  return fmt;
};
let date = new Date();
let today = date.Format("yyyy-MM-dd");

export default {
  name: "AddWorkInfo",
  data() {
    return {
      workType: [
        { value: "固定", label: "固定" },
        { value: "临时", label: "临时" }
      ],
      workSex: [{ value: "男", label: "男" }, { value: "女", label: "女" }],
      formWorkInfo: {
        name: "",
        publishtime: today,
        title: "",
        type: "",
        worktime: "",
        location: "",
        workplace: "",
        pay: "",
        deadline: "",
        sex: "",
        grade: "",
        place: "",
        need: "",
        people: ""
      }
    };
  },
  methods: {
    addWorkInfo() {
      this.$axios
        .post("/WorkStudyInfo", this.formWorkInfo)
        .then(res => {
          this.$message.success(res.data.message);
        })
        .catch(error => {
          console.log(error);
        });
    }
  }
};
</script>

<style scoped></style>
